<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="viewport" id="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no"/>
<title>个人主页</title>
<link href="/static/webAPP/css/reset.css" rel="stylesheet" type="text/css">
<link href="/static/webAPP/css/personal-center.css" rel="stylesheet" type="text/css">
<style>
   .img-info a{
      float: left;
      width: 100%;
   }
   .img-info a img{
      width: 100%;
      height: 100%;
   }
   .level-imgInfo{
      width: 22px;
      height: 19px;
      position: absolute;
      top: 80px;
      left: 70px;
   }
   .level-imgInfo img{
      width: 100%;
      height: 100%;
   }
   .level-nameInfo{
      position: absolute;
      top: 85px;
      left: 105px;
      width: 60px;
      height: 20px;
      background-color: #fff;
      border-radius: 15px;
      font-size: 12px;
      text-align: center;
      line-height: 20px;
      color: #FF9101;
   }
   .level-menoy{
      font-size: 13px;
      color: #664630;
      position: absolute;
      top: 55px;
      right: 8px;
   }
   .level-menoyInfo{
      font-size: 23px;
      color: #fff;
   }
   .personal-box1-title{
      width: 100%;
      float: left;
      height: 25px;
      line-height: 25px;
      margin-bottom: 10px;
   }
   .personal-box1-txt1{
      font-size: 16px;
      font-weight: bold;
   }
   .personal-box1-txt2{
      font-size: 12px;
      color: #ccc;
      float: right;
   }
   .personal-box1-title img{
      width: 15px;
      height: 15px;
      float: right;
      margin-top: 5px;
   }
</style>
</head>
<body>
<div class="near-box">
      <div class="index-bigbox" style="margin-top: 0px;">
          <!--头部开始-->
          <div class="personal-top">
          	 <img src="./images/599aa36d5e4a4.jpg" alt="" class="personal-img">
          	 <div class="personal-top-box1">
          	 	<span class="personal-top-img1"><img src="/static/webAPP/images/people1.png" alt=""></span>
          	 	<div class="personal-top-box2">
          	 		<span class="personal-top-text1">未登录</span>
                 </div>
                 <div class="level-imgInfo"></div>
                 <div class="level-nameInfo">普通用户</div>
                 <a href="./membercenter.html" class="level-menoy">账户余额:<i class="level-menoyInfo">0.00</i>元</a>
          	 </div>
          </div>
          <div class="img-info">
             <a href="javascript:void(0);"><img src="/static/webAPP/images/huiyuankaitong.png" alt=""></a>
            </div>
          <!--头部结束--> 
          <!--代付款分类开始-->
          <div class="personal-box1 mbt-05">
               <a href="/static/webAPP/my-indent-all.html" class="personal-box1-title">
                  <span class="personal-box1-txt1">我的订单</span>
                  <img src="/static/webAPP/images/arrow-right.png" alt="">
                  <span class="personal-box1-txt2">查看全部订单</span>
               </a>
                <a href="/static/webAPP/my-indent-dfk.html" class="personal-box2 box3">
          	      <span class="personal-box1-img1"><img src="/static/webAPP/images/personal-center-img1.png" alt=""><i class="order-num payOrder-num">0</i></span>
          	      <span class="personal-box1-text1">待付款</span>
          	   </a>
                <a href="/static/webAPP/my-indent-dfh.html" class="personal-box2 box3">
          	      <span class="personal-box1-img1"><img src="/static/webAPP/images/personal-center-img2.png" alt=""><i class="order-num deliverOrder-num">0</i></span>
          	      <span class="personal-box1-text1">待发货</span>
          	   </a>
                <a href="/static/webAPP/my-indent-dsh.html" class="personal-box2 box3">
          	      <span class="personal-box1-img1"><img src="/static/webAPP/images/personal-center-img3.png" alt=""><i class="order-num receiveOrder-num">0</i></span>
          	      <span class="personal-box1-text1">待收货</span>
          	   </a>
                <a href="/static/webAPP/my-indent-tkdd.html" class="personal-box2 box3">
          	      <span class="personal-box1-img1"><img src="/static/webAPP/images/personal-center-img4.png" alt=""></span>
          	      <span class="personal-box1-text1">退款订单</span>
          	   </a>
                <!-- <a href="/static/webAPP/my-indent-all.html" class="personal-box2 box3">
          	      <span class="personal-box1-img1"><img src="/static/webAPP/images/personal-center-img5.png" alt=""></span>
          	      <span class="personal-box1-text1">全部订单</span>
          	   </a> -->
          </div>
          <!--代付款分类结束-->
          <!--功能分类开始-->
          <!-- <a href="javascript:void(0);" class="personal-box5">
          	  <span class="personal-box5-img1"><img src="./images/personal-center-img10.png" alt=""></span>
          	  <span>我的优惠券</span>
          </a> -->
          <a href="/static/webAPP/machineplace.html" class="personal-box5">
          	  <span class="personal-box5-img1"><img src="/static/webAPP/images/personal-center-img11.png" alt=""></span>
          	  <span>收货地址</span>
          </a>
          <a href="javascript:void(0);" class="personal-box5">
          	  <span class="personal-box5-img1"><img src="/static/webAPP/images/personal-center-img12.png" alt=""></span>
               <span>售后服务电话</span>
               <span style="float: right;">0551-68660616</span>
          </a>
          <a href="javascript:void(0);" class="Logininfo"></a>
          <!-- <span class="personal-box5-text2">退出登录</span> -->
      </div>
      <!--bigbox结束-->
      <div class="kaola-bottom">
          <a href="/static/webAPP/index.html" class="kaola-bottom-box1">
               <span class="kaola-bottom-img1"><img src="/static/webAPP/images/home2.png"></span>
               <span class="kaola-bottom-text1">首页</span>
          </a>
          <a href="/static/webAPP/classify.html" class="kaola-bottom-box1">
               <span class="kaola-bottom-img1"><img src="/static/webAPP/images/fenlei1.png"></span>
               <span class="kaola-bottom-text1">分类</span>
          </a>
          <a href="/static/webAPP/shoping-cart.html" class="kaola-bottom-box1">
               <span class="kaola-bottom-img1"><img src="/static/webAPP/images/shop-cart1.png"></span>
               <span class="kaola-bottom-text1">购物车</span>
          </a>
          <a href="/static/webAPP/personal-center.html" class="kaola-bottom-box1">
               <span class="kaola-bottom-img1"><img src="/static/webAPP/images/people2.png"></span>
               <span class="kaola-bottom-text1 text2">我的</span>
          </a>
     </div>
</div>
<script src="/static/webAPP/js/jquery-1.8.3.min.js"></script>
<script src="/static/webAPP/lib/mobile/layer.js"></script>
<script>
   $(function(){
      if(sessionStorage.getItem("need-refresh")){
			location.reload();
			sessionStorage.removeItem("need-refresh");
      }
       
      //判断是否登录
      var userName = sessionStorage.getItem("sessionName")
      if (userName == null || userName == '' || userName == undefined) {
         $(".Logininfo").html('<span class="personal-box5-text2 userLogin">用户登录</span>')
         // 取消事件的默认行为
         $(".box3").click(function (e) {
            e.preventDefault();
         });
         layer.open({
            content: '是否去往登录界面？',
            btn: ['去登陆', '不要'],
            shadeClose: false,
            yes: function(index){
            // window.location = "./login.html";
               var userAgent = navigator.userAgent.toLowerCase();
					if(userAgent.match(/MicroMessenger/i) == "micromessenger") {
						window.location = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx45db0b3d36e1f241&redirect_uri=https%3A%2F%2Fvm.fowotek.com%2Fstatic%2FwebAPP%2Fweichatlogin.html&response_type=code&scope=snsapi_userinfo&#wechat_redirect";
					}else{
						window.location = "/static/webAPP/login.html";
					}
            }
         });
         
      }else{
         $(".Logininfo").html('<span class="personal-box5-text2 logout">退出登录</span>')

         var wxResponseUserInfo = sessionStorage.getItem("sessionuserWxResponseUserInfo")
         if (wxResponseUserInfo != null && wxResponseUserInfo != '' && wxResponseUserInfo != undefined) {
            $(".personal-top-img1").html('<img src="'+ wxResponseUserInfo +'" alt="">')
         }

         $.ajax({
            type: "get",
                        //TODO:
            url: "/app/userInfo/" + userName,
            data: '',
            dataType: "json",
            success: function(mag){
				   sessionStorage.setItem("sessionUserid", mag.data.id)
				   sessionStorage.setItem("sessionUsernickname", mag.data.nickname)
					
               var data = mag.data
               $(".personal-top-box2").html('<span class="personal-top-text1" user_id="'+ data.id +'">'+ data.nickname +'</span>')
               $(".payOrder-num").html(data.bookOrderStatus.to_pay)
               $(".deliverOrder-num").html(data.bookOrderStatus.to_deliver)
               $(".receiveOrder-num").html(data.bookOrderStatus.to_receive)
               var membership = mag.data.membership
               var level
               var userMony
               if (membership == null || membership == undefined || membership == '') {
                     level = 0
                     userMony = ''
               }else{
                     level = membership.level
                     userMony = membership.remaining_amount
               }
               sessionStorage.setItem("sessionMembershiplevel", level)
               sessionStorage.setItem("sessionMembershipremaining", userMony)
               if (level == 2) {
                     $(".level-nameInfo").html('会员用户')
                     $(".level-imgInfo").html('<img src="/static/webAPP/images/huiyuaninfo.png" alt="">')
                     $(".img-info").html('')
                     $(".level-menoyInfo").html(userMony)
               }else{
                     $(".level-nameInfo").html('普通用户')
                     $(".level-imgInfo").html('')
                     $(".img-info").html('<a href="/static/webAPP/membercenter.html"><img src="/static/webAPP/images/huiyuankaitong.png" alt=""></a>')
                     $(".level-menoyInfo").html('0.00')
               }
            },
            error: function(){
               
               layer.open({
                  content: '登录超时，请退出重新登录',
                  skin: 'msg',
                  time: 3 //2秒后自动关闭
               });
               sessionStorage.removeItem("sessionName")
               // window.location = "/static/webAPP/login.html";
               var userAgent = navigator.userAgent.toLowerCase();
					if(userAgent.match(/MicroMessenger/i) == "micromessenger") {
						window.location = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx45db0b3d36e1f241&redirect_uri=https%3A%2F%2Fvm.fowotek.com%2Fstatic%2FwebAPP%2Fweichatlogin.html&response_type=code&scope=snsapi_userinfo&#wechat_redirect";
					}else{
						window.location = "/static/webAPP/login.html";
					}
            }
         })
         
      }

      //退出登录
      $(".logout").click(function(){
         layer.open({
            content: '是否要退出登录？',
            btn: ['退出', '取消'],
            yes: function(index){
               sessionStorage.removeItem("sessionName")
               window.location = "/static/webAPP/personal-center.html";
            }
         });
      })

      $(".userLogin").on("click",function(){
         layer.open({
            content: '是否去往登录界面？',
            btn: ['去登陆', '不要'],
            shadeClose: false,
            yes: function(index){
            window.location = "/static/webAPP/login.html";
            }
         });
      })
   })
   
</script>
</body>
</html>